//
//  WeekDaysView.m
//  carcareIOS
//
//  Created by ileo on 16/6/28.
//  Copyright © 2016年 chezheng. All rights reserved.
//

#import "WeekDaysView.h"

@implementation WeekDaysView

-(void)setDateComponents:(NSArray<NSDateComponents *> *)dateComponents monthFirstDay:(NSDate *)monthFirstDay isShowOneMonth:(BOOL)isShowMonth{
    if (self.dataSource) {
        CGFloat width = self.width / 7;
        CGFloat height = self.height;
        NSInteger max = 7;
        for (int i = 0; i < max; i++) {
            NSDateComponents *components = dateComponents[i];
            UIView<DayView> *dayView = [self.dataSource dayViewWithDateComponents:components monthFirstDay:monthFirstDay isShowOneMonth:isShowMonth];
            dayView.left = width * i;
            dayView.width = width - 1;
            dayView.height = height;
            NSInteger tag = i + 1;
            dayView.tag = tag;
            [[self viewWithTag:tag] removeFromSuperview];
            [self addSubview:dayView];
        }
    }
}

@end
